package com.jy.appmarket.utils;

import java.io.File;

import android.content.Context;
import android.os.Environment;

public class StorageConfig {

	/** SD卡目录 */
	public static String SDCARD_DIR = Environment.getExternalStorageDirectory().getAbsolutePath();
	public static final String SOME_COOLPAD_SDCARD_DIR = "/mnt/internal";
	static {
		if (!Environment.getExternalStorageDirectory().exists() && new File(SOME_COOLPAD_SDCARD_DIR).exists()) {
			SDCARD_DIR = SOME_COOLPAD_SDCARD_DIR;
		}
	}

	/** 软件根目录 */
	public static String ROOT_DIR = SDCARD_DIR + "/AppMarket";

	/** 下载根目录 */
	public static String DOWNLOAD_DIR = ROOT_DIR + "/download";

	/** 更新根目录 */
	public static String UPDATE_DIR = ROOT_DIR + "/update";

	/** 缓存根目录 */
	public static String CACHE_DIR = ROOT_DIR + "/cache";

	public static File SHOW_LOCAL_FILE = new File(ROOT_DIR + "/settings", "local");

	public static void setCacheDir(Context ctx) {
		File sdcard = new File(SDCARD_DIR);
		if (!sdcard.exists() || !sdcard.canWrite()) {
			File cache = ctx.getCacheDir();
			if (!cache.exists()) {
				cache.mkdir();
			}
			CACHE_DIR = cache.getAbsolutePath() + "/AppMarket/cache";
		}
	}
}
